package cn.microven.mindmap.oprations;

import cn.microven.mindmap.components.node.AbstractMapNode;
import cn.microven.mindmap.struture.MindMap;
import javafx.scene.paint.Color;

public class ChangeFontColorOperation implements Operation{

    public Color oldColor;

    public Color newColor;

    public AbstractMapNode node;

    public ChangeFontColorOperation(Color oldColor, Color newColor, AbstractMapNode node){
        this.oldColor = oldColor;
        this.newColor = newColor;
        this.node = node;
    }



    @Override
    public void start(boolean isRedo) {
        node.setFontColor(newColor);
        if (!MindMap.getInstance().isUndoing() && !MindMap.getInstance().isRedoing()) {
            MindMap.addOperation(this);
        }

    }

    @Override
    public void undo() {
        node.setFontColor(oldColor);
    }
}
